/**初始事件绑定的初始化*/
$(document).ready(function(){
 	//绑定所有的页面查询回车响应
	$(".easyui-validatebox.unsearch-desc").live('keydown',function(event) {
		//必须要把keydown事件都屏蔽掉
 	 	if(event.keyCode==13){
 	 		event.stopPropagation();
 	 		event.preventDefault();
 	 		return;
 	 	}
 	});
 	$(".easyui-validatebox.unsearch-desc").live('keyup',function(event) {
 	 	if(event.keyCode==13){
 	 		event.stopPropagation();
 	 		event.preventDefault();
 	 	 	$(this).parent().find('.public-qry-btn1').first().click();
 	 	 	$(this).parent().find('.public-qry-query').first().click();
 	 	}
 	});
 	//绑定查询输入框的focus事件，以使置灰的风格消失
 	$(".easyui-validatebox.search-desc").live('focus',function(event){
 		if($(this).attr('oldValue')==$(this).val()){
 			$(this).val('');
 		}
 		$(this).removeClass('search-desc');
 		$(this).addClass('unsearch-desc');
 	});
 	
 	//绑定查询输入框的focus事件，以使置灰的风格消失
 	$(".easyui-validatebox.search-desc-content").live('focus',function(event){
 		$(this).removeClass('search-desc-content');
 		$(this).addClass('unsearch-desc');
 	});
 	//绑定查询输入框的blur事件，以使置灰的风格消失
 	$(".easyui-validatebox.unsearch-desc").live('blur',function(event){
 		if(jQuery.trim($(this).val()).length==0){
 			$(this).val($(this).attr('oldValue'));
 			$(this).removeClass('unsearch-desc');
 			$(this).addClass('search-desc');
 		}else{
 			$(this).removeClass('unsearch-desc');
 			$(this).addClass('search-desc-content');
 		}
 		
 	});
 	//关闭按钮绑定
 	$(".public-btn1.closeTab").live('click',function(event){
 		closeTab();
 	});
 	//查询按钮绑定
	$(".public-qry-btn1").live('click',function(event){
	 	event.stopPropagation();
	 	event.preventDefault();
		var qryFormId = "#"+$(this).parents('form:first').attr("id");
		if($(qryFormId+" .easyui-validatebox.search-desc").val()==$(qryFormId+" .easyui-validatebox.search-desc").attr('oldValue')){
			$(qryFormId+" .easyui-validatebox.search-desc").val('');
			jqQueryForm(qryFormId,function(){
				$(qryFormId+" .easyui-validatebox.search-desc").val($(qryFormId+" .easyui-validatebox.search-desc").attr('oldValue'));
			},function(form_){
					jqValidateForm(form_);
			});
		}else{
			jqQueryForm(qryFormId,null,function(form_){
					jqValidateForm(form_);
			});
		}
 	});
	$(".public-qry-btn1").click();
	//查询按钮绑定
	$(".public-qry-query").live('click',function(event){
	 	event.stopPropagation();
	 	event.preventDefault();
		var qryFormId = "#"+$(this).parents('form:first').attr("id");
		if($(qryFormId+" .easyui-validatebox.search-desc").val()==$(qryFormId+" .easyui-validatebox.search-desc").attr('oldValue')){
			$(qryFormId+" .easyui-validatebox.search-desc").val('');
			jqQueryForm(qryFormId,function(){
				$(qryFormId+" .easyui-validatebox.search-desc").val($(qryFormId+" .easyui-validatebox.search-desc").attr('oldValue'));
			},function(form_){
					jqValidateForm(form_);
			});
		}else{
			jqQueryForm(qryFormId,null,function(form_){
					jqValidateForm(form_);
			});
		}
 	});
	$(".public-qry-query").click();
	$(".qry-query").hover(function(){$(".qry-query_child").show();}, function(){$(".qry-query_child").hide();});
	
	$(".tr1").live('mouseover', function(event){
		$(this).removeClass("tr1");
    $(this).addClass("tr2");
	});
	$(".tr2").live('mouseout', function(event){
		$(this).removeClass("tr2");
    $(this).addClass("tr1");
	});
	$('#centerTab').tabs({
		tools:[{
			iconCls:'icon-back',
			title:"注销",
			handler: function(){
				$.messager.confirm('注销提示', '你确定注销吗?', function(r){
					if(r){
						window.location = 'logout';
					}
				});
			}
		}]
	});
});
//********************************以下是easyui关于tab的操作*********************************************************************
/**
 * 根据标题查找table
 */
findTab=function(title){
	var tab=null;
	var tabs=$('#centerTab').tabs('tabs');
	$(tabs).each(function(i){
		if(this.panel('options').title == title){
			tab=this;
			return false;
		}
	});
	return tab;
};
/**
 * 根据标题查找table的index
 */
findTabIndex=function(title){
	var index = -1;
	var tabs=$('#centerTab').tabs('tabs');
	$(tabs).each(function(i){
		if(this.panel('options').title == title){
			index = i;
			return false;
		}
	});
	return index;
};
/**
 * 打开frame
 * title:标题
 * url:打开地址
 * iconCls:图标
 */
openFrameTab=function(title, url,iconCls){
	var tabIndex=findTabIndex(title);
	if(tabIndex!=-1){
		$('#centerTab').tabs('select', tabIndex);
/*		$('#centerTab').tabs().tabs('update', {
			tab: tab,
			options:{
				selected:true
			}
		});*/
		return;
	}
	
	$('#centerTab').tabs('add',{
		title:title,
		content:'<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>',
		iconCls:iconCls,
		closable:true
	});
};

/**
 * 打开frame
 * title:标题
 * url:打开地址
 * iconCls:图标
 * callback:回调函数
 * desc：描述
 */
openTopTab=function(title,url,iconCls,callback,desc){
	var tabIndex=findTabIndex(title);
	if(tabIndex!=-1){
		$('#centerTab').tabs('select', tabIndex);
/*		$('#centerTab').tabs().tabs('update', {
			tab: tab,
			options:{
				selected:true
			}
		});*/
		return;
	}
	if(top.UIManager)
		top.UIManager.Tab.open(url,function(){if(callback)callback();},title,desc);
	else{
		top.$('#centerTab').tabs('add',{
			title:title,
			content:'<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>',
			iconCls:iconCls,
			closable:true
		});
	}
};

/**
 * 通用的查询功能，并在指定区域显示查询结果
 * @param form	form的id，包括“#”前缀
 * @param fn	提交前执行的function
 * @param bfn	服务器返回后执行的function
 */
jqQueryForm=function(form,fn,bfn,pageNum){
	$form=$(form);
	$form.ajaxSubmit({
		type:"post",
		contentType: "application/x-www-form-urlencoded; charset=utf-8",
		target:form+"List",
		beforeSubmit:function(formData, jqForm, options){
		  if(bfn)return bfn(jqForm[0]);
		},
		beforeSend:showProgressDialog,
		complete:hideProgressDialog,
		error:function(xhr, textStatus, errorThrown){
			var msg=xhr.responseText + "" + "";
			msg = _replaceError(msg);
			showMsgDialog(msg,'错误信息','error');
		},
		success:function(response){
			if(fn){
				response = _replaceError(response);
				fn(response);
			}
		}
	});
};
//==================================================================公共表单处理
/**
 * 提交表单
 * 通过缺省form表单的action提交，即页面只有一个表单。
 * 
 * @param callback	服务器返回后执行的function
 */
xsubForm=function(callback){
	var sform = $('form');
	var sId = sform.attr("id");
	subForm(sId,function(data){},callback);
};

/**
 * 提交表单
 * 通过form表单的action提交
 * @param frmId		form的id，
 * @param prefun	提交前执行的function
 * @param callback	服务器返回后执行的callback
 */
subForm=function(frmId,prefun,callback){
	var formId = '#'+frmId;
	$form=$(formId);
	$form.ajaxSubmit({
		type:"post",
		contentType: "application/x-www-form-urlencoded; charset=utf-8",
		beforeSubmit:function(formData, jqForm, options){
			if(prefun)return prefun(jqForm[0]);
		},
		beforeSend:function(xhr){
			if(prefun){
				prefun(xhr);
			}
			showProgressDialog();
		},
		complete:hideProgressDialog,
		error:function(xhr, textStatus, errorThrown){
			var msg=xhr.responseText + "" + "";
			msg = _replaceError(msg);
			showMsgDialog(msg,'错误信息','error');
		},
		success:function(response){
			if(fn){
				response = _replaceError(response);
				callback(response);
			}
		}
	});
};

/**
 * 提交表单
 * 通过ajax提交
 * @param frmId		form的id
 * @param url		提交url
 * @param prefun	提交前执行的function
 * @param callback	服务器返回后执行的function
 */
submitForm=function(frmId,url,prefun,callback){
	$.ajax({
		type:'post',
		contentType: "application/x-www-form-urlencoded; charset=utf-8",
		beforeSend:function(xhr){
			if(prefun){
				prefun(xhr);
			}
			showProgressDialog();
		},
		complete:hideProgressDialog,
		url:url,
		data:$('#'+frmId).serialize(),
		async: false,
		error:function(xhr, textStatus, errorThrown){
			var msg=xhr.responseText + "" + "";
			msg = _replaceError(msg);
			showMsgDialog(msg,'错误信息','error');
		},
	    success:function(data,textStatus){
	    	if(callback){
	    		callback(data,textStatus);
	    	}
	    }
	});
};
//========================================删除
/**
 * 删除提交表单
 * 确定页面只有一个表单，且用于查询
 * 
 * @param itemIdField		结果列表中checkbox的name
 * @param delUrl			删除时远端url
 */
xdelRows=function(itemIdField,delUrl){
	var sfrm = $('form');
	var sId = sfrm.attr("id");
	var sUrl = sfrm.attr("action");
	
	delRows(itemIdField,delUrl,sId,sUrl);
};

/**
 * 删除提交表单
 * 通过ajax提交
 * @param itemIdField		结果列表中checkbox的name
 * @param delUrl			删除时远端url
 * @param queryFrmId		查询条件Form ID
 * @param queryUrl			查询条件Form url
 */
delRows=function(itemIdField,delUrl,queryFrmId,queryUrl){
	var sDelUrl = delUrl;
	var sQueryUrl = queryUrl;
	var sItemIdField = itemIdField;
	var params=[];
	//处理
	var checkboxInput = 'input[name="'+sItemIdField+'"]:checked';
	$(checkboxInput).each(function(){ 
           var _val=$(this).val(); 
           params.push(_val);
    }); 
	var param = params.join(",");
    if(param=="" || param == null){
        alert("请选择一条删除记录");
    }else {
  	  if(param.indexOf(",")!=-1) {
  		  if(window.confirm("选择了多条数据，确定要执行批量删除操作吗？")) {
  			  $.get(sDelUrl,{ids:param},function(data){
                    alert("删除数据成功");
                    $('#'+queryFrmId).action = sQueryUrl;
                    $('#'+queryFrmId).submit();                                                        
           	 });     
      	  };
        }else {
      	  if(window.confirm("确定要删除该数据吗？")){
      		  $.get(sDelUrl,{ids:param},function(data){
                    alert("删除数据成功");
                    $('#'+queryFrmId).action = sQueryUrl;
                    $('#'+queryFrmId).submit();                                    
           	   });  
             };       
        };
    };
};

/**
 * 选择项检查
 * 有选择项，返回true；否则，false。
 * 
 * @param itemIdField		结果列表中checkbox的name
 */
selectionCheck = function(itemIdField){
	var checkboxInput = 'input[name="'+sItemIdField+'"]:checked';
	$(checkboxInput).each(function(){ 
        var _val=$(this).val(); 
        params.push(_val);
	});
	var param = params.join(",");
	if(param=="" || param == null){
		return false;
	}
	return true;
};

/**
 * 唯一性校验
 * 
 * @param fieldName		需要校验的字段名
 * @param value			需要校验的字段值
 * @param checkUrl		校验的url地址
 * @param callback		校验回调函数
 */
uniqueCheck=function(fieldName,value,checkUrl,callback){
	$.get(checkUrl,{fieldName:value},function(data){
		if(callback){
			callback(data);
		}
	});  
};

/**
 * 反选
 * 
 * @param checkboxId	控制checkboxID
 * @param itemIdField	结果列表中checkbox的name
 */
invertSelection=function(checkboxId,itemIdField){
	var sCheckBoxId = '#'+checkboxId;
	var sItemIdField = 'input[name="'+itemIdField+'"]';
	
	$(sCheckBoxId).bind('click',function(){
		$(sItemIdField).each(function(){
			if(this.checked){
				$(this).removeAttr("checked");
			}else{
				$(this).attr("checked","true");     
			}
		});           
	});  
};

/**
 * 绑定打开窗口事件
 * 
 * @param btnId			按钮Id
 * @param url			窗体内容url
 * @param filter		打开窗口过滤器函数。返回true，则打开；否则，反之。
 * @param callback		关闭窗体时回调函数
 * @param options		打开窗口时，一些参数
 */
bindClickOpenWin = function(btnId,url,filter,callback,options){
	var btn = '#'+btnId;
	var title = "弹出窗口";
	var param = {};
	$(btn).bind('click',function(){
		if(filter && filter(param)){
			options["param"] = param;
			openWindow(title,url,callback,options);
		}
	});
};

/**
 * 绑定单击事件
 * 
 * @param btnId			窗口标题
 * @param clickListener	按钮单击事件
 */
bindClick = function(btnId,clickListener){
	var btn = '#'+btnId;
	$(btn).bind('click',clickListener);
};

/**
 * 打开窗口
 * 
 * @param title			窗口标题
 * @param url			窗体内容url
 * @param callback		关闭窗体时回调函数
 * @param option		打开窗口时，一些参数
 */
openWindow=function(title,url,callback,options){
	$("body").append("<div id='win'></div>");
	var rqstBaseUrl = url+"?1=1";
	if(options){
		if(options["param"]){
			var param = options["param"];
			$.each(param,function(key,value){
				rqstBaseUrl += "&";
				rqstBaseUrl += key+"="+value;
			});
		}
	}
	
	$('#win').dialog({  
		title	: 	title,  
	    width	: 	900,  
	    height	: 	450,  
	    closed	: 	false,  
	    cache	: 	false,  
	    href	: 	rqstBaseUrl,  
	    onClose : 	callback,
	    modal	: 	true  
	}); 
};
//*****************************************************************************************************

_replaceError=function(msg){
	msg = msg.replace('<b>businessexception</b>','');
	msg = msg.replace('systemexception','');
	return msg;
};
/**
 * 弹出方式的提示框，并显示给定提示信息
 * @param msg
 * @param title
 * @param icon
 * @param fn
 */
showMsgDialog=function(msg,title,icon,fn){
	var type='1';
	if(icon=='error'){
		type='2';
	}else if(icon=='info'){
		type='1';
	}else if(icon=='warn'){
		type='3';
	}
	msg = _replaceError(msg);
	$.messager.alert(title,msg,icon,fn);
};

/*注意有fn时需要自己销毁divObj对象*/
msgBox=function(title,text,fn,width,height,okTitle,cancelTitle){
	var divObj = _getDialogDiv(title,text);
	if(okTitle==undefined){okTitle="确定";}if(cancelTitle==undefined){cancelTitle="取消";}
	var btn = [{
    text:okTitle,
    handler:function(){
    	if(fn){
    		fn(true,divObj);
    	}else
    		divObj.dialog('destroy');
    	}
  	},{
  		text:cancelTitle,
  		handler:function(){
  			divObj.dialog('destroy');
  		}
  }];
	_dialog(divObj,width,height,btn);
	return divObj;
};

msgBoxViewClose=function(title,text,fn,width,height,cancelTitle){
	var divObj = _getDialogDiv(title,text);
	if(cancelTitle==undefined){cancelTitle="关闭";}
	var btn = [{
  		text:cancelTitle,
  		handler:function(){
  			divObj.dialog('destroy');
  		}
  }];
	_dialog(divObj,width,height,btn);
	return divObj;
};

/*获取容器层*/
_getDialogDiv=function(title,text){
	var style="";
	var html='<div title="'+ title+'" style="padding:5px;'+style+'">'+text+'</div>';
	var divObj=$(html);
	$.parser.parse(divObj);
	divObj.appendTo("body");
	return divObj;
};
/*显示容器层*/
_dialog=function(divObj,width,height,btn){
	divObj.dialog({
    modal:true,
    resizable:true,
    width:width,
    height:height,
    onClose:function(){
    	divObj.dialog('destroy');
    },
    buttons:btn
	});
};

//使用ajax方式提交form并返回执行结果，但是不需要返回页面的业务使用此函数
jqPostSubmit=function(form,fn,title,bfn){
	if(!title)title='提示信息';
	$form=$(form);
	addFormKillHtmlCacheParam($form[0]);
	$form.ajaxSubmit({
		dataType:'html',
		type:"post",
		contentType: "application/x-www-form-urlencoded; charset=utf-8",
		beforeSubmit:function(){
			if(bfn){
				return bfn($form[0]);
			}
		},
		beforeSend:showProgressDialog,
		complete:hideProgressDialog,
		error:function(xhr, textStatus, errorThrown){
			var msg=decodeURIComponent(xhr.responseText);
			showMsgDialog(msg,'错误信息','error');
		},
		success:function(response, textStatus, jqXHR){
			var msg=""+response;
			msg=msg.toLowerCase();
			var index=msg.indexOf("<b>businessexception</b>");
			if (index != -1){
				showMsgDialog(msg.replace('<b>businessexception</b>','').toUpperCase(),'错误信息','error');
				return;
			}
			index=msg.indexOf("systemexception");
			if (index != -1){
				response=decodeURIComponent(response);
				showMsgDialog(response,'错误信息','error');
				return;
			}
			//if(fn){fn();}
			showMsgDialog(response,title,'info',fn);
		}
	});
};

//提交请求后只需要一个提示信息，并不需要返回页面的场景需要
postUrl=function(url,fn,title){
	$.post(url,null,function(msg){
		if(fn)
			fn(msg);
		else
			showMsgDialog(msg, title, 'info');
	});
};

closeTab=function(){
	top.UIManager.Tab.thisClose();
};



strToDate=function(dateStr){ 
 	return new Date(Date.parse(dateStr.replace(/-/g,   "/")));
};

isNum=function(str){
	var regNum = new RegExp("^[0-9]*$");
	return regNum.test(str);
};

$$=function(id){
	return document.getElementById(id);
};


//动态删除行
function deleteUploadRow(tableId, rowNum){
	var tb = $$(tableId);
	tb.deleteRow(rowNum);
}

function getRowIndex(objTRChildrens)
{
	if(objTRChildrens.parentNode.tagName != "TR") {
		return getRowIndex(objTRChildrens.parentNode);
	}
	else {
		return objTRChildrens.parentNode.rowIndex;
	}
}

confirmMsgDialog=function(title,msg,fn){
	$.messager.confirm(title,msg,function(r){
		if(r){
			if(fn)fn();
		}
	});
};

promptMsgDialog=function(title,msg,fn){
	$.messager.prompt(title, msg, fn);
};

//将一个对象或多个对象转换为一个数组
function $A(obj) {
	if (obj != null) {
		if (obj.length == undefined || obj.length == 0 || (obj.type != undefined && obj.type.indexOf("select") != -1)) {
			var array = [];
			array.push(obj);
			return array;
		}
		return obj;
	}
	else {
		return [];
	}
}
/**
 *正则表达式验证	
 *regExp正则表达式
 *objStr目标字符串
 */
regObj = function(regExp, objStr) {
	return new RegExp(regExp).test(objStr);
};
/**
 *验证字符串是否为空，空格也能去掉
 *objStr目标字符串
 */
isEmpty = function(objStr) {
	if (objStr == ""||objStr==undefined) {
		return true;
	}
	var regExp = "^[ ]+$";
	var regExp2 = "[\u3000]";
	return (regObj(regExp, objStr)||regObj(regExp2, objStr));
};
/**
 *通过正则表达式求字符串长度
 *objStr目标字符串
 */
calculateStrLen = function(objStr) {
	return objStr.replace(/[^\x00-\xff]/g, "^^").length;
};
/**
 * 统一对表单校验。
 */
function jqValidateForm(form) {
	var isOk = true;
	var warnStr = "";
	var invalidFiled = new Array();
	for (var i = 0; i < form.length; i++) {
		var widget = form.elements[i];
		if(widget.disabled){
			continue;
		}
		
		//判断附近不允许为空
		if (widget.type.indexOf("hidden")!=-1 && widget.className=='attachList'){
			var pNode = widget.parentNode;
			var tables = pNode.getElementsByTagName("TABLE");
			var table=tables[0];
			var count=0;
			
			if(tables[0].className=='attachListTable'){
				count=table.getElementsByTagName("TR").length;
				table=tables[1];
			}
			
			if (count==0){
				var ee = table.getElementsByTagName("input");
				for(var j=0;j<ee.length;j++){
					var e=ee[j];
					if(e.type=="file" && e.value != "")
						count++;
				}
			}
			if(count==0){
				isOk = false;
				warnStr += widget.getAttribute("emptyMessage") + "<br>";
			}
			continue;
		}
		
		value=widget.value;
		required=widget.getAttribute("required") == "true" || widget.getAttribute("rrequired");
//		required=widget["required"] == "true"||widget["rrequired"] == "true";
		if (widget.type.indexOf("text") != -1||widget.type.indexOf("hidden") != -1 || widget.type.indexOf("file") != -1) {
			if (required) {
				//如果是含有"_displayed_"，则表示是日期控件，不需要校验,dojo的日期控件不能在这个for循环里校验是否为空
				if (widget.id && widget.name.indexOf("_displayed_") != -1){
					//进一步判断是否真的是dojo的日期控件，只有ie会出现这种情况，firefox对于仅有id的那个控件不包含在form.elements中
					var widget2 = dijit.byId(widget.id);
					if (widget2 && widget2.declaredClass=="dijit.form.DateTextBox"){
						continue;
					}
				}
				
				if(widget.className!=null){
					if (widget.className.indexOf('easyui-datetimebox')!=-1){
						value=$('#'+widget.id).datetimebox("getValue");
					}else if (widget.className.indexOf('easyui-datebox')!=-1){
						value=$('#'+widget.id).datebox("getValue");
					}
				}

				if (isEmpty(value)) {
					isOk = false;
					invalidFiled.push(widget);
					warnStr += widget.getAttribute("emptyMessage") + "<br>";
				} else {
					if (widget.getAttribute("regExp") != "" && widget.getAttribute("regExp") != undefined) {
						if (!regObj(widget.getAttribute("regExp"), value)) {
							isOk = false;
							invalidFiled.push(widget);
							warnStr += widget.getAttribute("invalidMessage") + "<br>";
						}
					}
					if (widget.getAttribute("maxLength") != "" && widget.getAttribute("maxLength") != undefined) {
						if (calculateStrLen(value) > widget.getAttribute("maxLength")) {
							isOk = false;
							invalidFiled.push(widget);
							warnStr += widget.getAttribute("lengthError") + "<br>";
						}
					}
					if (widget.getAttribute("minLength") != "" && widget.getAttribute("minLength") != undefined) {
						if (calculateStrLen(value) < widget.getAttribute("minLength")) {
							isOk = false;
							invalidFiled.push(widget);
							warnStr += widget.getAttribute("lengthError") + "<br>";
						}
					}
				}
			} else {
				if (!isEmpty(value)) {
					if (widget.getAttribute("regExp") != "" && widget.getAttribute("regExp") != undefined) {
						if (!regObj(widget.getAttribute("regExp"), value)) {
							isOk = false;
							invalidFiled.push(widget);
							warnStr += widget.getAttribute("invalidMessage") + "<br>";
						}
					} 
					if (widget.getAttribute("maxLength") != "" && widget.getAttribute("maxLength") != undefined) {
						if (calculateStrLen(value) > widget.getAttribute("maxLength")) {
							isOk = false;
							invalidFiled.push(widget);
							warnStr += widget.getAttribute("lengthError") + "<br>";
						}
					}
					if (widget.getAttribute("minLength") != "" && widget.getAttribute("minLength") != undefined) {
						if (calculateStrLen(value) < widget.getAttribute("minLength")) {
							isOk = false;
							invalidFiled.push(widget);
							warnStr += widget.getAttribute("lengthError") + "<br>";
						}
					}
				}
			}
		}else if(widget.type.indexOf("password") != -1){
			if (isEmpty(value)) {
					isOk = false;
					invalidFiled.push(widget);
					warnStr += widget.getAttribute("emptyMessage") + "<br>";
				} else {
					if (widget.getAttribute("maxLength") != "" && widget.getAttribute("maxLength") != undefined) {
						if (calculateStrLen(value) > widget.getAttribute("maxLength")) {
							isOk = false;
							invalidFiled.push(widget);
							warnStr += widget.getAttribute("lengthError") + "<br>";
						}
					}
				}
		}else if (widget.type.indexOf("select") != -1) {
			if (required) {
				if (isEmpty(value)) {
					isOk = false;
					invalidFiled.push(widget);
					warnStr += widget.getAttribute("emptyMessage") + "<br>";
				}
			}
		}else if (widget.type.indexOf("radio") != -1) {
			if (required) {
				var emptyMessage = widget.getAttribute("emptyMessage");
				var subRadios = $A(form[widget.name]);
				var isNull = true;
				for (var loop = 0; loop < subRadios.length; loop++) {
					if (subRadios[loop].checked) {
						isNull = false;
					}
				}
				if (isNull == true) {
					invalidFiled.push(widget);
					isOk = false;
					warnStr += emptyMessage + "<br>";
				}
			}
		}else if (widget.type.indexOf("checkbox") != -1) {
			if (required) {
				var emptyMessage = widget.getAttribute("emptyMessage");
				var subCheckboxs = $A(form[widget.name]);
				var isNull = true;
				for (var loop = 0; loop < subCheckboxs.length; loop++) {
					if (subCheckboxs[loop].checked) {
						isNull = false;
						break;
					}
				}
				if (isNull == true) {
					invalidFiled.push(widget);
					isOk = false;
					warnStr += emptyMessage + "<br>";
				}
			}
		}
	}
	if(!isOk)
		showMsgDialog(warnStr, "验证结果",'warning');
	 
	return isOk;
}

var progressDialog=null;
var progressDialog2=null;
showProgressDialog=function(){
	var imgSrc = "../resources/images/common/loadingPic.gif";
	$("<div id=\"loadingPic1\" class=\"loading\" style=\"background-color:black;position:fixed;left:0;top:0;\"></div>").appendTo("body");
	$("<div id=\"loadingPic2\" class=\"picbg\" style=\"position:absolute;text-align:center;left:50%;top:50%;margin-top: -16px;margin-left: -16px;\"></div>").appendTo("body");
	$("#loadingPic2").append("<img src='" + imgSrc + "'/> <br />加载中...");
};
hideProgressDialog=function(){
	$("#loadingPic1").remove();
	$("#loadingPic2").remove();
};

$(function(){
	$.messager.defaults={ok:"确定",cancel:"取消"};   
});

getTimestampId=function(){
	var date = new Date();
	return date.getTime();
};
addFormKillHtmlCacheParam=function(form){
	var url=form.action;
	var index=url.indexOf("&killHtmlCacheId=");
	if (index != -1)
		url=url.substring(0,index);
	form.action=url+"&killHtmlCacheId="+getTimestampId();
};